<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>两数求和功能</title>
    <!--引入外部js文件-->
    <script type="text/javascript" src="demo1.js"></script>
</head>
<body>
    num1:<input type="text" id="num1"><br/>
    num2:<input type="text" id="num2"><br/>
    <button onclick="sum()">求和</button>
    <div id="show"></div>
    <script>
        //调用demo1.js中定义的求和方法
        function sum() {
            //获取两个输入框的值
            var num1=document.getElementById("num1").value;
            var num2=document.getElementById("num2").value;
            var total=add(num1,num2);
            //将求和结果展示在div
            document.getElementById("show").innerText="两个数值相加结果是："+total;
        }
    </script>
</body>
</html>